package com.turtle.security.organizates.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.turtle.security.organizates.constant.SysRoleConstant;
import com.turtle.security.organizates.dto.SysRoleDTO;
import com.turtle.security.organizates.entity.SysRole;
import com.turtle.security.organizates.mapper.SysRoleMapper;
import com.turtle.security.organizates.service.ISysRoleAddService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 添加系统角色
 *
 * @author turtle
 * date: 2020-06-01
 */
@Service
@AllArgsConstructor(onConstructor = @__(@Autowired))
public class SysSystemRoleAddServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleAddService {

    private final SysRoleMapper sysRoleMapper;

    /**
     * 获取角色类型
     *
     * @return roleType
     */
    @Override
    public String getRoleType() {
        return SysRoleConstant.SYSTEM_ROLE_TYPE;
    }

    /**
     * 添加系统角色
     *
     * @param sysRole 角色信息
     */
    @Override
    public void roleAdd(SysRoleDTO sysRole) {
        SysRole role = SysRole.builder()
            .roleName(sysRole.getRoleName())
            .roleSort(sysRole.getRoleSort())
            .roleKey(sysRole.getRoleKey())
            .status(sysRole.getStatus())
            .remark(sysRole.getRemark())
            .roleType(SysRoleConstant.SYSTEM_ROLE_TYPE)
            .build();
        sysRoleMapper.insert(role);

    }


}
